package com.itheima.service;

import com.itheima.dao.UserMapper;
import com.itheima.daomain.User;
import com.itheima.util.SessionFactoryUtils;
import org.apache.ibatis.session.SqlSession;

/**
 * @Descriptionn:test
 * @Create by:依然
 * @Date:2021/11/2 20:19
 */
public class addUserService {
    public Integer addUser(User user) {
        SqlSession sqlSession = SessionFactoryUtils.getSession();
        UserMapper mapper = sqlSession.getMapper(UserMapper.class);
        Integer integer = mapper.interuser(user.getName(), user.getSex(), user.getAge(), user.getAddress(), user.getQq(), user.getEmail());
        System.out.println(user);
        if (integer > 0) {
            sqlSession.commit();
            return 1;
        }
        sqlSession.close();
        return 0;
    }

}
